const {queryMysql}=require('../utils/queryMysqlUtil')
const {UserNotExistError,UserPasswordError}=require('../commonError/UserError')
exports.verify=async function(username,password){
	const queryStr=`select * from chihiro_users where username='${username}'`
  let { results }=await queryMysql(queryStr).catch((err)=>{
    return Promise.reject(err)
  })
  if(results.length===0){
    return Promise.reject(new UserNotExistError())
  }
  if(results[0].password!==password){
    return Promise.reject(new UserPasswordError())
  }
  return Promise.resolve(results[0])
}
